<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
	<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>修改作息时间</title>
		<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
		<link href="css/table.css" rel="stylesheet" type="text/css" />
		<style type="text/css">
			body{FONT-FAMILY: 宋体;FONT-SIZE: 12px;}
		</style>
		<script src="js/My97DatePicker/WdatePicker.js" type="text/javascript"
			language="javascript"></script>
		<script type="text/javascript">
			function updateAttendTime(){
				var oasid=$("#oasid").val();
				var startTime =$("#startTime1").val();
				var amTime =$("#amTime").val();
				var amRest =$("#amRest").val();
				var pmTime =$("#pmTime").val();
				var pmRest =$("#pmRest").val();
				var nightTime =$("#nightTime").val();
				var nightRest =$("#nightRest").val();
				var note =$("#note").val();
				var status=$("#status").val();
				var reg=/^(\d{2}):(\d{2})$/;
				if($.trim(startTime)=='')
				{
					alert("开始时间不能为空！");
					return;
				}
				if($.trim(amTime)=='')
				{
					alert("请设置上午上班时间！");
					return;
				}
				if($.trim(amRest)=='')
				{
					alert("请设置上午休息时间！");
					return;
				}
				if($.trim(pmTime)=='')
				{
					alert("请设置下午午上班时间！");
					return;
				}
				if($.trim(pmRest)=='')
				{
					alert("请设置下午休息时间！");
					return;
				}
				if($.trim(nightRest)=='')
				{
					alert("请设置晚班休息时间！");
					return;
				}
				if($.trim(nightTime)=='')
				{
					alert("请设置晚班上班时间！");
					return;
				}
				if($.trim(status)=='')
				{
					status=0;
				}
				if(!reg.test(amTime)||!reg.test(amRest)||!reg.test(pmTime)||!reg.test(pmRest)||!reg.test(nightTime)||!reg.test(nightRest))
				{
					alert("请设置时间格式为hh:mm");
					return;
				}
				var add ={"oas.id":oasid,"oas.startTime":startTime,"oas.amTime":amTime,"oas.amRest":amRest,"oas.pmTime":pmTime,"oas.pmRest":pmRest,"oas.nightTime":nightTime,"oas.nightRest":nightRest,"oas.note":note,"oas.status":status};
				
				$.post("updateAttendanceTime.action",add,function(data){
					if(data=='success'){
						window.opener.location.reload();
						window.close();
					}else{
						alert("修改失败！");
					}
				});
			}
		</script>
	</head>
	<body>
		<table align="center" style="width:450px" class="righ_list" frame="box" cellspacing="1" cellpadding="0"   border="0">
			<tr ><td class="reigh_list2" align="center">作息时间</td></tr>
			<tr style="background: #ffffff">
				<td align="left">
					执 行 时 间  ：<input style="margin: 10px 0 0 0" name="startDate"
						value="<fmt:formatDate value="${oas.startTime}" pattern="yyyy-MM-dd" 

/>" class="Wdate" id="startTime1" type="text"
						readonly="readonly"
						onclick="WdatePicker({maxDate:'#F{$dp.$D(\'startTime1\',{d:-0});}'})"
						id="startTime1" /> 到  <input style="margin: 10px 0 0 0" name="startDate"
						value="<fmt:formatDate value="${oas.endTime}" pattern="yyyy-MM-dd" 

/>" class="Wdate" id="startTime2" type="text"
						readonly="readonly"
						onclick="WdatePicker({maxDate:'#F{$dp.$D(\'startTime2\',{d:-0});}'})"
						id="startTime2" />
				</td>
			</tr >
			<tr style="background: #ffffff">
				<td align="left">
					上午上班时间：<input id="amTime" type="text" width="100px" height="30px" value="${oas.amTime}"/>
				</td>
			</tr >
			<tr style="background: #ffffff">
				<td align="left">
					上午休息时间：<input id="amRest" type="text" width="100px" height="30px" value="${oas.amRest}"/>
				</td>
			</tr >
			<tr style="background: #ffffff">
				<td align="left">
					下午上班时间：<input id="pmTime" type="text" width="100px" height="30px" value="${oas.pmTime}"/>
				</td>
			</tr >
			<tr style="background: #ffffff">
				<td align="left">
					下午休息时间：<input id="pmRest" type="text" width="100px" height="30px" value="${oas.pmRest}"/>
				</td>
			</tr >
			<tr style="background: #ffffff">
				<td align="left">
					晚班上班时间：<input id="nightTime" type="text" width="100px" height="30px" value="${oas.nightTime}"/>
				</td>
			</tr >
			<tr style="background: #ffffff">
				<td align="left">
					晚班休息时间：<input id="nightRest" type="text" width="100px" height="30px" value="${oas.nightRest}"/>
				</td>
			</tr>
			<tr style="background: #ffffff">
				<td align="left">
					&nbsp; 备 &nbsp;&nbsp;&nbsp; 注 ：<input id="note" type="text" width="100px" height="30px" value="${oas.note}"/>
				</td>
			</tr >
			
			<tr style="background: #ffffff">
				<td  align="center">
					<input type="hidden" value="${oas.id }" id="oasid">
					<input class="button_02" onclick="updateAttendTime()" type="button" value="确定" />
				</td>
			</tr>
		</table>
	</body>
</html>